<?php

namespace common\models\byxcx;

use common\behaviors\MerchantBehavior;

/**
 * This is the model class for table "{{%oauth_client}}".
 *
 * @property string $id ID
 * @property string $title 标题
 * @property string $cate_id 分类ID(单选)
 * @property string $cover 图片
 * @property string $description 描述
 * @property int $status 状态
 * @property string $created_at 创建时间
 * @property string $updated_at 更新时间
 */
class Chart extends \common\models\base\BaseModel
{


    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%byxcx_chart}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [
                [
                    'cate_id',
                    'status',
                    'created_at',
                    'updated_at',
                ],
                'integer',
            ],
            [['title','cover'], 'required'],
            [['title'], 'string', 'max' => 50],
            [['cover', 'tag'], 'string', 'max' => 100],
            [['description'], 'string', 'max' => 200],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'title' => '标题',
            'cate_id' => '分类ID',
            'tag' => '标签',
            'cover' => '图片',
            'description' => '简单介绍',
            'status' => '状态',
            'cate.title'=>'分类',
            'created_at' => '创建时间',
            'updated_at' => '修改时间',
        ];
    }
    /**
     * 关联当前用户
     *
     * @return \yii\db\ActiveQuery
     */
    public function getCate()
    {
        return $this->hasOne(Cate::class, ['id' => 'cate_id']);
    }
}
